package com.bai.edu.controller;


import com.bai.edu.entity.subject.OneSubject;
import com.bai.edu.service.SubjectService;
import com.bai.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author bai
 * @since 2023-07-23
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class SubjectController {
    @Autowired
    private SubjectService subjectService;

    //TODO:添加课程分类
    @PostMapping("addSubject")
    public R addsubject(MultipartFile file) {
        //上传文件
        subjectService.saveSubject(file, subjectService);
        return R.ok();
    }

    //TODO:课程分类列表
    @GetMapping("getAllSubject")
    public R getAllSubject() {
       List<OneSubject> list= subjectService.getAllOneTwoSubject();
        return R.ok().data("list",list);
    }
}

